package com.zzq.calcgame.storage;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 用户设置
 */
public class UserSetting {
    int DEFAULT_QUESTION_COUNT=20;//默认题目产总数
    String SETTING_NAME="user_setting.xml";

    SharedPreferences sp;

    int questionCount=DEFAULT_QUESTION_COUNT;//题目产总数
    public UserSetting(Context ctx) {
        sp=ctx.getSharedPreferences(SETTING_NAME,Context.MODE_PRIVATE);
    }

    public int getQuestionCount() {
        return sp.getInt("questionCount",questionCount);
    }

    /**
     * 保存用户设置
     * @return
     */
    public boolean save(){
        SharedPreferences.Editor editor=sp.edit();
        editor.putInt("questionCount",getQuestionCount());
        return editor.commit();
    }
}
